

***************************************************
* 1.13.2022
* Replication files for 
* "Informal Work, Risk and Clientelism: Evidence from 223 Slums Across India"
* British Journal of Political Science 
* Estimated on Stata/SE 16.0
***************************************************
 
use "inf_work_main_analysis.dta", clear
 
****************************************************************************************
                           **Work characteristics**
****************************************************************************************

*****************************************
*Figure 2
*****************************************
bysort female: tab occupation if occupation != 0 

*****************************************
*Figure 3
*****************************************
**Days worked**
qui g formaltext = "Formal" if formalwork == 1
qui replace formaltext = "Informal" if formalwork == 0

graph box daysworked if occupation != 0  & city == "Bangalore", over(formaltext) ytitle("") title("Days Worked in a Typical Month") saving(days, replace)

*Assets
twoway kdensity assets if occupation != 0 & formalwork == 1 & city == "Bangalore",  bwidth(3) || kdensity assets if occupation != 0 & formalwork == 0 & city == "Bangalore",  bwidth(3) title("Number of Assets Held") ytitle("") xtitle("Assets") legend(label(1 "Formal") label(2 "Informal")) saving(assets, replace)

**Pay freq**
g formality = "Formal" if formalwork == 1 
qui replace formality = "Informal" if formalwork == 0

graph pie if occupation != 0 & city == "Bangalore", over(payfreq) legend(cols(2)) legend(label(1 "Daily") label(2 "Weekly") label(3 "Monthly") label(4 "Seasonally")) by(, title(Frequency of Pay by Job Status)) by(formality, note(""))  saving(freq, replace)

**Worried about work**
graph pie if occupation != 0 & city == "Bangalore", over(worry_work) legend(cols(2)) legend(label(1 "Very worried") label(2 "A little worried") label(3 "Not at all worried")) by(, title(Concern about Finding Sufficient Work)) by(formality, note("")) saving(worry, replace)

gr combine "days" "worry" "freq" "assets"

*****************************************
*Figure 4
*****************************************
bysort occupation: tab payfreq 

*****************************************
*Figure 5
*****************************************
bysort occupation: tab worry_work if city == "Bangalore"

****************************************************************************************
                           **Preferences**
****************************************************************************************

*****************************************
*Figure 6
*****************************************

logit edupref formalwork assetscore primary migrant nh_age size i.landtype respondent_age  female scst muslim i.cityfactor, cluster(id) 
  margins, atmeans at(formalwork =(0 1))  vsquish post
  
logit schemes formalwork assetscore primary migrant nh_age size i.landtype respondent_age  female scst muslim  i.cityfactor, cluster(id) 
  margins, atmeans at(formalwork =(0 1))  vsquish post

   *Additional model output (for supplemental materials)
logit edupref formalwork##cityfactor assetscore primary migrant nh_age size i.landtype respondent_age  female scst   muslim i.cityfactor if occupation != 0, cluster(id) 

logit edupref occupation assetscore primary migrant nh_age size i.landtype respondent_age  female scst muslim i.cityfactor if occupation != 0, cluster(id) 

logit edupref i.occupation assetscore primary migrant nh_age size i.landtype respondent_age  female scst muslim i.cityfactor if occupation != 0, cluster(id) 

logit schemes formalwork##cityfactor assetscore primary migrant nh_age size i.landtype respondent_age  female scst   muslim i.cityfactor if occupation != 0, cluster(id) 

logit schemes  occupation assetscore primary migrant nh_age size i.landtype respondent_age  female scst muslim i.cityfactor if occupation != 0, cluster(id) 

logit schemes i.occupation assetscore primary migrant nh_age size i.landtype respondent_age  female scst muslim i.cityfactor if occupation != 0, cluster(id) 

****************************************************************************************
                           **Exchanges**
****************************************************************************************

*****************************************
*Figure 7A: Contacts broker only
*****************************************

**Contacts broker only
logit nh_lonly i.occupation assetscore primary migrant nh_age size i.landtype respondent_age  female scst muslim  i.cityfactor if occupation != 0 , cluster (id)
  margins, atmeans at(occupation =(1 2 3 4 5))  vsquish post

   *Additional model output (for supplemental materials)
logit nh_lonly formalwork assetscore primary migrant nh_age size i.landtype respondent_age  female scst muslim  i.cityfactor if occupation != 0 , cluster (id)

logit nh_lonly formalwork##i.cityfactor assetscore primary migrant nh_age size i.landtype respondent_age  female scst muslim if occupation != 0 , cluster (id)

logit nh_lonly occupation assetscore primary migrant nh_age size i.landtype respondent_age  female scst muslim  i.cityfactor if occupation != 0 , cluster (id)

logit nh_lonly i.occupation assetscore primary migrant nh_age size i.landtype respondent_age  female scst muslim  i.cityfactor if occupation != 0 , cluster (id)


*****************************************
*Figure 7B: Politician in network (pull in social networks data)
*****************************************

use "networks_data.dta", clear 

**Politician in social network
logit politician i.occupation female scst muslim respondent_age hh_head migrant edu tarp mould pat if occupation != 0, cluster (AA7_AreaNeighbourhood)
  margins, atmeans at(occupation =(1 2 3 4 5))  vsquish post

   *Additional model output (for supplemental materials)
logit politician occupation female scst muslim respondent_age hh_head migrant edu tarp mould pat if occupation != 0, cluster (AA7_AreaNeighbourhood)
 
logit politician i.occupation female scst muslim respondent_age hh_head migrant edu tarp mould pat if occupation != 0, cluster (AA7_AreaNeighbourhood)


*****************************************
**SET UP LIST EXPERIMENTS (pull household survey data back in)
*****************************************

use "inf_work_main_analysis.dta", clear
 
foreach var in lse2_1l74 lse2_2l75 lse2_3l76 {
destring `var', replace force
qui replace `var' = . if `var' > 5
}

qui replace lse2_1l74 = . if lse2_1l74 > 3
qui replace lse2_2l75 = . if lse2_2l75 > 4


g treat1 = (lse2_2l75 != .)
qui replace treat1 = . if lse2_3l76 != .

g treat2 = (lse2_3l76 != .)
qui replace treat2 = . if lse2_2l75 != .

qui g list = lse2_2l75 if treat1 == 1
qui replace list = lse2_3l76 if treat2 == 1
qui replace list = lse2_1l74 if treat1 == 0


*****************************************
*Figure 8
*****************************************

reg list treat1 if year!= "2017" , cluster(id)

reg list treat2 if year!= "2017" , cluster(id)

   *Conditioned by labor status(for supplemental materials)
   reg list treat1 if formalwork == 1 & occupation != 0 & year!= "2017", cluster(id)

   reg list treat1 if formalwork == 0 & occupation != 0 & year!= "2017", cluster(id)

   reg list treat2 if formalwork == 1 & occupation != 0 & year!= "2017", cluster(id)
   
   reg list treat2 if formalwork == 0 & occupation != 0 & year!= "2017", cluster(id)

   
